package com.cp.core.controller.admin;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cp.base.util.JwtUtils;
import com.cp.common.result.R;
import com.cp.common.result.ResponseEnum;
import com.cp.core.pojo.entity.UserInfo;
import com.cp.core.pojo.query.UserInfoQuery;
import com.cp.core.pojo.vo.LoginVo;
import com.cp.core.pojo.vo.RegisterVo;
import com.cp.core.pojo.vo.UserInfoVo;
import com.cp.core.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 用户基本信息 前端控制器
 * </p>
 *
 * @author ming
 * @since 2022-07-27
 */
@RestController
@RequestMapping("/admin/core/userInfo")
@Api(tags = "会员管理")
@Slf4j
//@CrossOrigin
public class AdminUserInfoController {
    @Resource
    UserInfoService userInfoService;
    @ApiOperation("根据条件分页查询")
    @GetMapping("/list/{page}/{limit}")
    public R listPage(@ApiParam("当前页码") @PathVariable("page") Long page,
                      @ApiParam("每页显示个数") @PathVariable("limit")Long limit,
                      @ApiParam(value = "查询对象",required = false) UserInfoQuery userInfoQuery){
        Page<UserInfo> pageEntity = new Page<>(page,limit);
        IPage<UserInfo> pageModel = userInfoService.listPage(pageEntity,userInfoQuery);
        return R.ok().data("page",pageModel);
    }
    @PutMapping("/lockeOrUnlocke")
    public R lock(Long id,Integer status){
      userInfoService.lockOrUnLock(id,status);
      String message = status==1?"解锁成功":"锁定成功";
      return R.ok().message(message);
    }
}

